using Abp.Application.Services.Dto;
using Batman.Cms.Core.Controllers;
using Batman.Cms.Core.Models.Mvc;
using Batman.Jianbei.Forum.Areas.Forum.Filters;
using Batman.Jianbei.Forum.Core.Domains.Socials;
using Batman.Jianbei.Forum.Services.Socials;
using Microsoft.AspNetCore.Mvc;

namespace Batman.Jianbei.Forum.Areas.Forum
{
    [Area("Forum")]
    public class FollowController : BatmanController<Follow>
    {
        public FollowService FollowService { get; set; }

        /// <summary>
        /// 关注某个人
        /// </summary>
        /// <param name="wxUId"></param>
        /// <returns></returns>
        public IActionResult Follow(string wxUId)
        {
            string currentWxUserId = User.GetWxUserId();

            ResponseBase result = FollowService.Follow(wxUId, currentWxUserId);

            return Json(result);
        }


        /// <summary>
        /// 取关
        /// </summary>
        /// <param name="wxUId"></param>
        /// <returns></returns>
        public IActionResult Unfollow(string wxUId)
        {
            string currentWxUserId = User.GetWxUserId();

            ResponseBase result = FollowService.Unfollow(wxUId, currentWxUserId);

            return Json(result);
        }

        #region 查询 我的关注/谁关注我

        /// <summary>
        /// 我的关注
        /// </summary>
        /// <returns></returns>
        public IActionResult MyFollowing(PagedResultRequestDto page)
        {
            var result = FollowService.GetFollows(page, new FollowFilter { FollowBy = User.GetWxUserId() });
            return Json(result);
        }

        /// <summary>
        /// 谁关注我
        /// </summary>
        /// <param name="page"></param>
        /// <returns></returns>
        public IActionResult MyFollower(PagedResultRequestDto page)
        {
            var result = FollowService.GetFollows(page, new FollowFilter { WxUserId = User.GetWxUserId() });
            return Json(result);
        }

        #endregion


        #region 查询 某人的关注/谁关注某人


        /// <summary>
        /// 获取被谁关注列表
        /// </summary>
        /// <param name="page"></param>
        /// <returns></returns>
        public IActionResult TheFollower(PagedResultRequestDto page, FollowFilter filter)
        {
            var result = FollowService.GetFollows(page, filter);
            return Json(result);
        }


        /// <summary>
        /// 获取关注列表
        /// </summary>
        /// <returns></returns>
        public IActionResult TheFollowing(PagedResultRequestDto page, FollowFilter filter)
        {
            var result = FollowService.GetFollows(page, filter);
            return Json(result);
        }

        #endregion

    }
}